$(document).ready(function(){
	$('#tree-cate').tree({
		url: 'list-cate.htm',
		onClick: onCateClick
	});
	$('#grid-product').datagrid({
		onSelect: onRowSelect
	});
	$('#grid-image').datagrid({url: 'list-image.htm'});
});

function onCateClick(node){
	$('#grid-product').datagrid({url:'list.htm?id='+node.id});
}

function onRowSelect(index, data){
	if(data.product_image != null){
		$('#image-default').html('<img src="' + data.product_image + '" width="100%" height="100%"/>');
	}
	$('#grid-image').datagrid({url: 'list-image.htm?id='+data.id});
}

function onAddImage(){
	var row = $('#grid-product').datagrid('getSelected');
	if(row){
		var api = $.dialog({
			id: 'dialog_' + new Date().getTime()
		});
		$.ajax({
			url: 'image-form.htm',
			success: function(data){
				api.content(data);
			},
			cache: false
		});
		/**
		$.dialog({
			title: '添加产品图片',
			width: 410,
			height: 170,
			content: 'url:product/image-form.htm'
		});
		**/
	}else{
		window.parent.showMsg('请选择一条产品记录！',true);
	}
}

function onDelImage(){
	
}